<?php

    class dictionaries_class
    {

        public $dic = Array();
        
        public function __construct($lpu_guid)
        {
            $this->getdata($lpu_guid);
        }
        
        public function getdata($lpu_guid)
        {
            global $mikron;
            $this->dic = $mikron->Cache->getCache('dictionaries2');
            if(is_array($this->dic))
            {
                return true;
            }
            $this->dic = Array();
            $buf = $mikron->Cache->getCache('dictionaries1');
            if(is_null($buf))
            {
                $xml = CreateGetDictionariesXML(constant('DATEBEGIN'), constant('DATEEND'), $lpu_guid);
                $buf = CallSoap('dictionaries', $xml);
                $mikron->Cache->setCache('dictionaries1', $buf);
            }
            $dom1 = new DomDocument();
            $dom1->loadXML($buf);
            $dictionaries_elm = $dom1->getElementsByTagName("dictionaries");
            $i = 0;
            foreach($dictionaries_elm as $dictionary_tag)
            {
                $dictionaries = $dictionary_tag->getElementsByTagName("dictionary");
                foreach($dictionaries as $dictionary)
                {
                    $for = $dictionary->getAttribute("for");
                    $elements = $dictionary->getElementsByTagName("element");
                    $this->dic[$for][null] = null;
                    foreach($elements as $element)
                    {
                        $code = $element->getAttribute("code");
                        $value = $element->getAttribute("value");
                        $template = $element->getAttribute("template");
                        if($template!="")
                        {
                            $code .= ",$template";
                        }
                        $this->dic[$for][$code] = $value;
                    }
                }
            }
            $mikron->Cache->setCache('dictionaries2', $this->dic);
        }
    }

    /*?><pre><?php
    print_r($dictionaries->dic);*/
    
?>